package com.miaoshaproject.error;
// 包装器模式业务类型实现
public class BusinessException extends Exception implements CommonError {
    private CommonError commonError;
    // 直接接受EmBusinessError的传参用于构造业务异常
    public  BusinessException(CommonError commonError){
        super();
        this.commonError=commonError;
    }

    // 接受自定义errMsg的方式构造业务异常
    public BusinessException(CommonError commonError,String errMsg){
        super();
        this.commonError=commonError;
        this.commonError.setErrorMsg(errMsg);
    }
    @Override
    public int getErrCode() {
        return this.commonError.getErrCode();
    }

    @Override
    public String getErrMsg() {
        return this.commonError.getErrMsg();
    }

    @Override
    public CommonError setErrorMsg(String errorMsg) {
        this.commonError.setErrorMsg(errorMsg);
        return this;
    }
}
